﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL_V1.App_Code.DBBroker;
using EntityObjects;

namespace BAL.Controller
{
    public class ItemAdjustmentControl
    {
        AdjustmentDBBroker adjustmentRef;
        public ItemAdjustmentControl()
        {
            adjustmentRef = AdjustmentDBBroker.getAdjustmentDBBroker();
        }
        public List<Adjustment> getVouchers()
        {
            return adjustmentRef.selectAllAdjustment();
        }

        public List<AdjustmentDetails> getAdjustmentDetailsByVoucherId(string vid)
        {
            return adjustmentRef.selectAdjDetailsByAdjVoucherId(vid);
        }

        public Boolean UpdateVoucherStatud(string vid,string status,string remark)
        {
            Adjustment adj = adjustmentRef.selectAdjustment(vid);
            adj.AdjStatus = status;
            adj.Remark = remark;
            adj.ApprovedDate = Convert.ToDateTime(adj.ApprovedDate).ToString();
            adj.ApprovedBy = "10001";
            adj.ApprovedDate = DateTime.Today.ToString();
            
            int flag = adjustmentRef.updateAdjustment(adj,vid);
            if (flag == 1) return true;
            else return false;
        }
    }
}
